package com.group3.group3.common.control;

import com.alibaba.fastjson.JSON;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class BaseController {
    @Resource
    private MessageSource messageSource;
    public String getSuccessMessag(String key,String ... arg){
        Map<String,Object> rstMap = new HashMap<>();
        Locale locale = LocaleContextHolder.getLocale();
        String msgStr =messageSource.getMessage(key,arg,locale);
        rstMap.put("success",true);
        rstMap.put("msg", msgStr);
        return JSON.toJSONString(rstMap);
    }
}
